package org.iabako.shared.iservice.user;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.iabako.client.tools.IabakoAsyncCallback;
import org.iabako.shared.entity.business.ClientCommunication;
import org.iabako.shared.entity.business.Payment;
import org.iabako.shared.entity.business.Sale;
import org.iabako.shared.entity.enumeration.IabakoPackage;
import org.iabako.shared.entity.user.Enterprise;
import org.iabako.shared.entity.user.User;
import org.iabako.shared.entity.user.UserPayPalToken;
import org.iabako.shared.entity.user.UserPayPalTokenUser;
import org.iabako.shared.exception.IabakoPackageForbiddenException;
import org.iabako.shared.exception.IabakoUniqueConstraintException;
import org.iabako.shared.iservice.generic.CRUDService;
import org.iabako.shared.iservice.generic.SearchService;

import java.util.List;
import java.util.Map;

/**
 * Created by jose on 24/09/14.
 */

@RemoteServiceRelativePath("iabakoServices/userService")
public interface UserService extends CRUDService, SearchService, RemoteService {

    User getUserByEmail(String username);

    User save(User entity) throws IabakoUniqueConstraintException;

    void reloadNotifications(Enterprise enterprise, boolean forced);

    void setUserPayPalTokenPayed(String iabakoTxId, String payPalPayerEmail, String payPalResponse);

    void calculateUserCredit(boolean isUpgrade, User user, IabakoPackage iabakoPackage, int quantity);

    UserPayPalToken getUserPayPalTokenPayedOrToVerify(String iabakoTxId);

    void setUserPayPalTokenToVerify(String transactionId, String payPalResponse);

    void setUserPayPalTokenCanceled(String transactionId, String payPalResponse);

    List<User> getUsersBySessionEnterprise();

    String savePayPalToken(UserPayPalToken payPalToken, List<UserPayPalTokenUser> userTokens);

    void addInvoiceReceiptToEnterpriseBalance(Sale sale, Payment payment) throws IabakoPackageForbiddenException;

    void addCommunicationToEnterpriseBalance(ClientCommunication clientCommunication);

    User getPrincipalUser();
}
